package org.iteam.core.service.oracle.impl.base;

import java.sql.SQLException;
import java.util.List;

import org.iteam.core.model.base.BaseIndustry;
import org.iteam.core.service.DBService;
import org.iteam.core.service.base.BaseIndustryService;

public class BaseIndustryServiceImpl extends BaseIndustryService {

	@Override
	public List<BaseIndustry> queryByPage(long page, long rows, String parent)
			throws SQLException {
		if (parent == null || "".equals(parent)) {
			String SQL = "SELECT * FROM BASE_INDUSTRY WHERE PARENT IS NULL ORDER BY CODE ";
			return super.query(DBService.toOraclePage(SQL), page * rows, rows
					* (page - 1));
		} else {
			String SQL = "SELECT * FROM BASE_INDUSTRY WHERE PARENT = ? ORDER BY CODE ";
			return super.query(DBService.toOraclePage(SQL), parent,
					page * rows, rows * (page - 1));
		}
	}

	@Override
	public List<BaseIndustry> queryByPage(long page, long rows)
			throws SQLException {
		String SQL = "SELECT * FROM BASE_INDUSTRY ORDER BY CODE";

		return super.query(DBService.toOraclePage(SQL), page * rows, rows
				* (page - 1));
	}

}
